package edu.sctu.practice.class01.wulixia.month09_wlx.test03;

/**
 * Created by wulixia on 2015/10/14.
 */
public class MyTime {

    private int hour;
    private int minute;
    private int second;
    public int addhour = 0;
    public int addminute = 0;
    public int subhour = 0;
    public int subminute = 0;

    public MyTime(int hour, int minute, int second) {
        this.hour = hour;
        this.minute = minute;
        this.second = second;
    }

    public String isPlay(){
        String time = hour + "时" + minute + "分" + second +"秒";
        return time;
    }

    public int addSecond(int sec){
        System.out.println("增加的秒数为：" + sec);
        second = second + sec;

        while (second >= 60){
            second = second - 60;
            addminute = addminute + 1;
        }
        return second;
    }

    public int addMinute(int min){
        System.out.println("增加的分钟数为：" + min);
        minute = minute + min + addminute;

        while(minute >= 60){
            minute = minute - 60;
            addhour = addhour + 1;
        }
        return minute;
    }

    public int addHour(int hou){
        System.out.println("增加的小时数为：" + hou);
        hour = hour + hou + addhour;

        while(hour >= 24){
            hour = hour - 24;
        }
        return hour;
    }

    public int subSecond(int sec){
        System.out.println("减少的秒数为：" + sec);
        second = second - sec;

        while(second < 0){
            second = second + 60;
            subminute = subminute +1;
        }
        return second;
    }

    public int subMinute(int min){
        System.out.println("减少的分钟数为：" + min);
        minute = minute - min -subminute;

        while(minute < 0){
            minute = minute + 60;
            subhour = subhour + 1;
        }
        return minute;
    }

    public int subHour(int hou){
        System.out.println("减少的小时数为：" + hou);
        hour = hour - hou - subhour;

        while (hour < 0){
            hour = 24 + hour;
        }
        return hour;
    }
}
